package com.mall.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.entity.LogisticsCompany;
import com.mall.mapper.LogisticsCompanyMapper;
import com.mall.service.ILogisticsCompanyService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 物流公司表 服务实现类
 * </p>
 *
 * @author ShouPeng
 * @since 2023-04-16
 */
@Service
public class LogisticsCompanyServiceImpl implements ILogisticsCompanyService {
    final
    LogisticsCompanyMapper logisticsCompanyMapper;

    public LogisticsCompanyServiceImpl(LogisticsCompanyMapper logisticsCompanyMapper) {
        this.logisticsCompanyMapper = logisticsCompanyMapper;
    }

    /**
     * 查询快递公司
     * @param page 页
     * @return list
     */
    @Override
    public IPage<LogisticsCompany> queryLogisticsCompany(Page<LogisticsCompany> page) {
        return logisticsCompanyMapper.selectPage(page,null);
    }

    /**
     * 查询快递公司
     *
     * @return list
     */
    @Override
    public List<LogisticsCompany> queryLogisticsCompany() {
        return logisticsCompanyMapper.selectList(null);
    }

    /**
     * 查询快递公司
     *
     * @param companyId id
     * @return pojo
     */
    @Override
    public LogisticsCompany queryLogisticsCompanyById(Integer companyId) {
        return logisticsCompanyMapper.selectById(companyId);
    }

    /**
     * 删除快递公司
     *
     * @param ids ids
     * @return success count
     */
    @Override
    public Integer deleteLogisticsCompany(List<String> ids) {
        return logisticsCompanyMapper.deleteBatchIds(ids);
    }

    /**
     * 修改快递公司
     *
     * @param logisticsCompany entity
     * @return bool
     */
    @Override
    public Boolean updateLogisticsCompany(LogisticsCompany logisticsCompany) {
        return logisticsCompanyMapper.updateById(logisticsCompany) > 0;
    }

    /**
     * 添加快递公司
     *
     * @param logisticsCompany entity
     * @return bool
     */
    @Override
    public Boolean addLogisticsCompany(LogisticsCompany logisticsCompany) {
        return logisticsCompanyMapper.insert(logisticsCompany) > 0;
    }
}
